const mysql = require("mysql");
const { mySqlConfig } = require("../../config/config.default");
const connection = mysql.createConnection(mySqlConfig);
connection.connect(function (err) {
  if (err) {
    console.error("error connecting: " + err.stack);
    return;
  }
  console.log("db connection success!");
});
const query = (sql) => {
  return new Promise((resolve, reject) => {
    connection.query(sql, function (error, results) {
      if (error) {
        reject(error);
      } else {
        resolve(results);
      }
    });
  });
};
module.exports = query;
